<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="tissue" tagdir="/WEB-INF/tags/tissueTags" %>
<%@ taglib prefix="extraction" tagdir="/WEB-INF/tags/tissueExtractionTags" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Edit Variable</title>
<jsp:include page="includes/header.jsp"></jsp:include>
<script type="text/javascript" src="scripts/common.js"></script>
<script type="text/javascript">
	function loadVarSelecter() {
		new Ajax.Updater('varSelecter','mainServlet', {
			method: 'POST',
			parameters: {appAction: 'ajaxFetchVarNames'},
			onFailure: function(transport){
				handleErrorResponseWindow(transport.responseText);
			}
		});
	}
	var eavVar;
	function loadVarInfo(){
		new Ajax.Request('mainServlet',{
			method: 'POST',
			parameters: {
				appAction: 'ajaxFetchVar',
				variableName: $('varSelecter').getValue()
			},
			onSuccess: function(transport){
				eavVar = transport.responseText.evalJSON();
				$('variableName').setValue(eavVar.variableName);
				$('humanReadableName').setValue(eavVar.humanReadableName);
				$('dataType').setValue(eavVar.dataType);
				if(eavVar.dataType=="VARCHAR"){
					$('dataType').setValue('TEXT');
				}
				else if(eavVar.dataType=="INT"){
					$('dataType').setValue('NUMERIC');
				}
				else{
					$('dataType').setValue(eavVar.dataType);	
				}
				$('deprecated').checked = eavVar.deprecated;
				$('description').setValue(eavVar.description);

			}
		});
	}
</script>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body onload="loadVarSelecter();">

<div id="container">
<div id="top">
<h1>CHC DB Web</h1>
</div>
<div id="leftnav"><jsp:include page="./includes/leftnav.jsp"></jsp:include></div>
<div id="content">
<h2>Edit Variable</h2>

<form >
<fieldset><legend>Select Variable</legend>

<label for="variableName">Full Name :</label>
<select id="varSelecter" onchange="loadVarInfo();">	
</select>
</fieldset>
</form>

<br/>
<div id="varInfoForm">
<form>
<fieldset><legend>Variable Info</legend>

<label for="variableName">Full Name: </label>
<input  type="text" id="variableName" size="60" maxlength="60"/>
<br/>

<label for="humanReadableName">Name: </label>
<input type="text" id="humanReadableName" size="60" maxlength="60"/>
<br/>

<label for="dataType">Data Type: </label>
<select id="dataType" >
<option>TEXT</option>
<option>NUMERIC</option>
<option>BOOLEAN</option>
</select>
<br/>

<label for="deprecated">Deprecated: </label>
<input type="checkbox" id="deprecated" >
<br/><br/>

<label for="description">Description: </label>
<textarea id="description" cols="52" rows="5">
</textarea>
<br/>



</fieldset>

</form>
</div>




</div>
<div id="footer"><jsp:include page="./includes/footer.jsp"></jsp:include></div>
</div>
</html>